var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, o) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var o in t)
              Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
          })(t, o);
      };
      return function (t, o) {
        function i() {
          this.constructor = t;
        }
        if ("function" != typeof o && null !== o)
          throw new TypeError(
            "Class extends value " + String(o) + " is not a constructor or null"
          );
        e(t, o),
          (t.prototype =
            null === o
              ? Object.create(o)
              : ((i.prototype = o.prototype), new i()));
      };
    })(),
  DepositHeroView = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.dataSource = []),
        (t.depositArr = []),
        (t.isNeedPayee = !0),
        (t.liushouListener = {
          caller: t,
          code: 1419,
          method: function (e) {
            if (0 == e.code) {
              var o;
              if (t.currentPage >= 1) {
                if (0 == e.list.length) return void t.currentPage--;
                for (s = 0; s < e.list.length; s++) {
                  var i = e.list[s];
                  t.depositArr.push(i), (t.dataSource = []);
                }
              } else (t.depositArr = e.list), (t.dataSource = []);
              t.isloading = !1;
              for (var s = 0; s < t.depositArr.length; s++) {
                var r = Utils.transform(
                    t.depositArr[s].roleType % 10,
                    "roleType"
                  ),
                  a = void 0;
                (a = "liushou" == t.depostype ? "留守" : "招领"),
                  (o = {
                    lbl_fujiangname: { text: t.depositArr[s].name },
                    lbl_fujiangstar: {
                      text: t.dealSuboardStar(t.depositArr[s].star),
                    },
                    fujianglvl: { text: t.depositArr[s].lvl + " 级" },
                    fujiangrole: { text: r },
                    fujiang_liushou: { label: a },
                    fujiangID: t.depositArr[s].id,
                    label_fujiang_index: { text: s + 1 + "." },
                  }),
                  t.dataSource.push(o);
              }
              t.list_liushouList.array = t.dataSource;
            } else ToastView.toastView(e.msg);
          },
        }),
        (t.zhaoLingstener = {
          caller: t,
          code: 1420,
          method: function (e) {
            0 == e.code
              ? ToastView.toastView("留守成功")
              : ToastView.toastView(e.msg);
          },
        }),
        (t.onLoadLiushouDataFn = {
          caller: t,
          code: 1420,
          method: function (e) {
            var o;
            "liushou" == t.depostype
              ? (ToastView.toastView("留守成功"), (o = "0"))
              : (ToastView.toastView(e.msg), (o = "2")),
              WebSocketService.send({ c: 1419, d: { action: o, pageNum: 0 } });
          },
        }),
        t.btn_depositback.on(Laya.Event.CLICK, t, t.onDepositBackFn),
        t.tab_depositHero.on(Laya.Event.CLICK, t, t.onTabDepositHeroFn),
        t.tab_second_hero.on(Laya.Event.CLICK, t, t.onSecondHeroAction),
        WebSocketService.addListener(t.liushouListener),
        WebSocketService.addListener(t.zhaoLingstener),
        (t.list_liushouList.selectEnable = !0),
        (t.list_liushouList.vScrollBarSkin = ""),
        (t.list_liushouList.renderHandler = new Laya.Handler(
          t,
          t.updateLiuShouItem
        )),
        (t.list_liushouList.scrollBar.changeHandler = new Handler(
          t,
          t.onLoadMoreData
        )),
        t.list_liushouList.on(
          Laya.Event.CLICK,
          t,
          t.onLiuShouFuJiangDidClickFn
        ),
        t
      );
    }
    return (
      __extends(t, e),
      (t.prototype.onLoadMoreData = function (e) {
        var t = e / this.list_liushouList.scrollBar.max,
          o = new Date(),
          i = !1;
        if (
          (o.getTime() - this.spaceTime >= 3e3 && (i = !0),
          1 == t && 0 == this.isloading && i)
        )
          return (
            (this.isloading = !0),
            this.currentPage++,
            0 == this.tab_second_hero.selectedIndex
              ? WebSocketService.send({
                  c: 1419,
                  d: { action: 2, pageNum: this.currentPage, sort: 1 },
                })
              : 1 == this.tab_second_hero.selectedIndex
              ? WebSocketService.send({
                  c: 1419,
                  d: { action: 2, pageNum: this.currentPage, sort: 2 },
                })
              : 2 == this.tab_second_hero.selectedIndex
              ? WebSocketService.send({
                  c: 1419,
                  d: { action: 2, pageNum: this.currentPage, sort: 3 },
                })
              : 3 == this.tab_second_hero.selectedIndex
              ? WebSocketService.send({
                  c: 1419,
                  d: { action: 2, pageNum: this.currentPage, sort: 4 },
                })
              : WebSocketService.send({
                  c: 1419,
                  d: { action: 2, pageNum: this.currentPage, sort: 0 },
                }),
            void (this.spaceTime = o.getTime())
          );
      }),
      (t.prototype.updateLiuShouItem = function (e, t) {
        if (!(t > this.depositArr.length)) {
          var o = e.getChildByName("label_fujiang_index"),
            i = e.getChildByName("lbl_fujiangname"),
            s = e.getChildByName("fujianglvl"),
            r = e.getChildByName("fujiangrole"),
            a = e.getChildByName("lbl_fujiangstar"),
            n = this.depositArr[t].s;
          (o.color = Dictionary.colorType[n]),
            (i.color = Dictionary.colorType[n]),
            (s.color = Dictionary.colorType[n]),
            (r.color = Dictionary.colorType[n]),
            (a.color = Dictionary.colorType[n]);
        }
      }),
      (t.openDepositView = function (e) {
        null == this.depositHeroVC && (this.depositHeroVC = new t()),
          (this.depositHeroVC.isNeedPayee = e),
          (this.depositHeroVC.dataSource = []),
          (this.depositHeroVC.depositArr = []),
          (this.depositHeroVC.list_liushouList.array = []),
          (this.depositHeroVC.currentPage = 0),
          (this.depositHeroVC.depostype = "liushou"),
          WebSocketService.send({
            c: 1419,
            d: { action: 0, pageNum: 0, sort: 0 },
          }),
          (this.depositHeroVC.tab_depositHero.selectedIndex = 0),
          (this.depositHeroVC.tab_second_hero.selectedIndex = -1),
          (this.depositHeroVC.tab_second_hero.visible = !1),
          (this.depositHeroVC.isloading = !1);
        var o = new Date();
        return (this.depositHeroVC.spaceTime = o.getTime()), this.depositHeroVC;
      }),
      (t.prototype.onTabDepositHeroFn = function () {
        0 == this.tab_depositHero.selectedIndex
          ? ((this.depostype = "liushou"),
            WebSocketService.send({
              c: 1419,
              d: { action: 0, pageNum: 0, sort: 0 },
            }),
            (this.tab_second_hero.visible = !1))
          : 1 == this.tab_depositHero.selectedIndex &&
            ((this.depostype = "zhaoling"),
            WebSocketService.send({
              c: 1419,
              d: { action: 2, pageNum: 0, sort: 0 },
            }),
            (this.tab_second_hero.visible = !0)),
          (this.currentPage = 0);
      }),
      (t.prototype.dealSuboardStar = function (e) {
        var t = "";
        return e > 0 && (t = e + "星"), t;
      }),
      (t.prototype.onLiuShouFuJiangDidClickFn = function (e) {
        if ((console.log(e.target.name), "" != e.target.name)) {
          var t =
            this.dataSource[this.list_liushouList.selectedIndex].fujiangID;
          if ("fujiang_liushou" == e.target.name)
            "liushou" == this.depostype
              ? (WebSocketService.send({
                  c: 1420,
                  d: { id: t, action: 1, pageNum: 0 },
                }),
                WebSocketService.addListener(this.onLoadLiushouDataFn))
              : "zhaoling" == this.depostype &&
                (WebSocketService.send({
                  c: 1420,
                  d: { id: t, action: 2, pageNum: 0 },
                }),
                WebSocketService.addListener(this.onLoadLiushouDataFn));
          else {
            var o = this.depositArr[this.list_liushouList.selectedIndex],
              i = AXSuboardinateDetailView.showSuboardView(o);
            i.pos(0, 35), Laya.stage.addChild(i);
          }
        }
      }),
      (t.prototype.onSecondHeroAction = function (e) {
        "item0" == e.target.name
          ? WebSocketService.send({
              c: 1419,
              d: { action: 2, pageNum: this.currentPage, sort: 1 },
            })
          : "item1" == e.target.name
          ? WebSocketService.send({
              c: 1419,
              d: { action: 2, pageNum: this.currentPage, sort: 2 },
            })
          : "item2" == e.target.name
          ? WebSocketService.send({
              c: 1419,
              d: { action: 2, pageNum: this.currentPage, sort: 3 },
            })
          : "item3" == e.target.name &&
            WebSocketService.send({
              c: 1419,
              d: { action: 2, pageNum: this.currentPage, sort: 4 },
            });
      }),
      (t.prototype.onDepositBackFn = function () {
        this.removeSelf();
      }),
      t
    );
  })(ui.HouseRoomController.DepositHeroViewUI);
